# Contributor: Denis Tolstov <tolstov_den@mail.ru>
# Maintainer: Denis Tolstov <tolstov_den@mail.ru>
pkgname=ptpd
pkgver=2.3.1
pkgrel=1
pkgdesc="Precision Time Protocol daemon"
options="!check" # No testsuite
url="https://github.com/ptpd/ptpd"
arch="all"
license="BSD-2-Clause"
makedepends="autoconf automake libtool
	libpcap-dev net-snmp-dev linux-headers"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/ptpd/ptpd/archive/ptpd-$pkgver.tar.gz
	ptpd-2.3.1-fix-libressl-compatibility.patch
	ptpd-2.3.1-fix-snmp.patch

	ptpd2.rc
	ptpd2.confd"
builddir="$srcdir/ptpd-$pkgname-$pkgver"

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-daemon
	make
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm755 src/ptpd2.conf.minimal "$pkgdir"/etc/ptpd2.conf
	install -Dm755 "$srcdir"/ptpd2.rc "$pkgdir"/etc/init.d/ptpd2
	install -Dm755 "$srcdir"/ptpd2.confd "$pkgdir"/etc/conf.d/ptpd2
}

sha512sums="25c128ce1920ae2c1469e986bfa5d5b8ebca04ec14b838fb8232b36e0a1ef94646507e1b25034846d11cf0f71d7e2da983b9f6408f8fcfc608904ecfec2a15c4  ptpd-2.3.1.tar.gz
19b6c3b3e248514d3374ac17f37070f60b43b5ba8d38b7564abd00896e2aecc29813f9a36bba2da7be33d6ff47aa029644d735f4325e948fe73ba81b466abc1d  ptpd-2.3.1-fix-libressl-compatibility.patch
40e6f89dc922da9b3a68f7513a4d08f8708a1f4ebb87147c6ab3e6a75d8aaa5a627045e967c5256445897175205c7b95e77f0ca7322062fa6265b7e909097978  ptpd-2.3.1-fix-snmp.patch
37af776a265fbabdabed381d98cf50d78a512634fd84ce07466a47a0e96a6b2cccfb762732a043139b6c136eefdc6443ab9a5cba1c30234b6c66acc23e98a5b2  ptpd2.rc
40ea56a92222eb10dc429343a23bdcc0e75f626e34fea139a09ca545a50aee0550253965de036218889554a2c0c7928c0051e3e71d9b9cd0a9d44d334e0bac47  ptpd2.confd"
